package Homework4;

public class MyIntegerArray {
    private int[] arr;

    public MyIntegerArray(int n) {
        this.arr = new int[n];
    }

    public MyIntegerArray(int[] arr) {
        this.arr = new int[arr.length];
        System.arraycopy(arr, 0, this.arr, 0, arr.length);
    }

    public int length() {
        return arr.length;
    }

    public void printArray() {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + (i < arr.length - 1 ? " " : ""));
        }
        System.out.println();
    }

    public void setElement(int index, int number) {
        arr[index] = number;
    }

    public int getElement(int index) {
        return arr[index];
    }

    public int getMax() {
        int max = arr[0];
        for (int num : arr) {
            if (num > max) max = num;
        }
        return max;
    }

    public int getMin() {
        int min = arr[0];
        for (int num : arr) {
            if (num < min) min = num;
        }
        return min;
    }

    public double getAvg() {
        double sum = 0;
        for (int num : arr) {
            sum += num;
        }
        return sum / arr.length;
    }
}

